package event

import (
	"context"
	"ez/apps/mes/auto/mc"
	mes "ez/apps/mes/document"
	"gitee.com/dreamwood/ez-go/ez"
)

func init() {
	ez.Subscribe(mc.CheckTemplateEventAfterSave, func(v interface{}, ctx context.Context) {
		md, ok := v.(*mes.CheckTemplate)
		if ok {
			md.LoadProcess()
			if md.Process != nil {
				md.DepartmentId = md.Process.DepartmentId
				md.SetEvent(false)
				_ = md.Save()
			}
		}
	})
}
